/**
 * 
 */
package com.alkandros.calculator.ui.photos;

import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;

import com.alkandros.calculator.R;
import com.alkandros.calculator.constants.IAppConstants;
import com.alkandros.calculator.manager.CustomProgressDialog;
import com.alkandros.calculator.manager.SelectorManager;
import com.alkandros.calculator.manager.Utils;

/**
 * @author Jiju Induchoodan
 *
 */
public class PhotosFragment extends Fragment implements IAppConstants,OnClickListener{

	private View rootView;
	private Button btnTrees;
	private Button btnScrubs;
	private Button btnWorks;
	private Context context;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState)
	{
		 rootView = inflater.inflate(R.layout.fragment_photos, container, false);
		 context = getActivity();
		 initialiseUI();
		 return rootView;
	}
	private void initialiseUI()
	{
		btnTrees 	 		= (Button)rootView. findViewById(R.id.btn_trees);  
		btnScrubs 	 		= (Button)rootView. findViewById(R.id.btn_scrub); 
		btnWorks 	 		= (Button)rootView. findViewById(R.id.btn_work);
		
		btnTrees.setOnClickListener(this);
		btnScrubs.setOnClickListener(this);
		btnWorks.setOnClickListener(this);
		
		Utils.setBackground(context, btnScrubs, 
				SelectorManager.getButtonDrawableByScreenCathegory(context, R.drawable.button_bg, R.drawable.button_press));
		Utils.setBackground(context, btnTrees, 
				SelectorManager.getButtonDrawableByScreenCathegory(context, R.drawable.button_bg, R.drawable.button_press));
		Utils.setBackground(context, btnWorks, 
				SelectorManager.getButtonDrawableByScreenCathegory(context, R.drawable.button_bg, R.drawable.button_press));

	}
	@Override
	public void onClick(View v) 
	{
		if(v==btnScrubs)
		{
			navigateToBrowser(SCRUB_PHOTOS);
		}
		else if(v==btnTrees)
		{
			navigateToBrowser(TREE_PHOTOS);
		}
		else if(v==btnWorks)
		{
			navigateToBrowser(WORK_PHOTOS);
		}
	}
	
	private void navigateToBrowser(String url)
	{
		Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
		startActivity(browserIntent);
	}
}
